home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / dev / gui / select_gc.lha / select_gc / select.doc < prev    next >
Encoding:
Text File  |  1999-07-21  |  43.5 KB  |  947 lines

  1. TABLE OF CONTENTS
  2.  
  3. select.gadget/--background--
  4. select.gadget/select.gadget
  5. select.gadget/ClearSelectGadget
  6. select.gadget/GetSGAttr
  7. select.gadget/InitSelectGadgetA
  8. select.gadget/ObtainSelectGClass
  9. select.gadget/SetSGAttrsA
  10. select.gadget/--background--                     select.gadget/--background--
  11.  
  12. DESCRIPTION
  13.  
  14. The select.gadget is a shared library which, when opened, adds to the system
  15. a public BOOPSI gadget class called "selectgclass". This class implements a
  16. button-like selection gadget, with features similar to those of a traditional
  17. GadTools cycle gadget, but with the additional ability to open, when pressed,
  18. a pop-up menu which allows the user to pick his choice more easily.
  19.  
  20. The look and behavior of the gadget and its pop-up menu can be configured
  21. using the attribute tags of the class.
  22.  
  23. The library is freeware; if you use it, you are allowed to distribute it
  24. with your software.
  25.  
  26. Some highlights:
  27.  
  28. - A delay can be set for the appearance of the pop-up menu, allowing for a
  29.   gadget which reacts like a normal cycle gadget upon "quick" clicks, and
  30.   like a pop-up gadget if the mouse button is kept pressed a little longer.
  31.   
  32. - The pop-up menu can appear and disappear with a vertical "zoom" effect
  33.   whose duration is configurable.
  34.  
  35. - It is optionally possible to have a "sticky" pop-up menu which remains
  36.   open when the mouse button is released.
  37.  
  38. - The gadget can be made "quiet", that is, the currently selected item can be
  39.   not displayed. Useful to attach a small pop-up button to string gadgets.
  40.  
  41. - The gadget can be configured to always behave like a cycle gadget, and
  42.   even like a plain button gadget.
  43.  
  44. - The gadget can broadcast changes in its value to target objects via the
  45.   BOOPSI notification system.
  46.  
  47. - All changes done with SetGadgetAttrsA() to the gadget's position, size
  48.   and look are visually executed in real-time.
  49.   
  50. - The gadget's dispatcher is able to swap the stack when needed.
  51.  
  52. - The gadget can be added to requesters and window borders.
  53.  
  54. - The pop-up menu can have a drop shadow.
  55.  
  56. - The gadget's "pop-up" symbol can be placed at the left side, at the right
  57.   side, or it can also not appear at all; its width is also configurable.
  58.   The gadget's default imagery for the symbol is fully scalable, and it can
  59.   be replaced by the application with a custom image.
  60.   
  61. - The default values for unspecified attributes can be globally set by the
  62.   user with an ASCII preferences file; the changes are applied in real-time
  63.   (to gadgets created afterwards) via file notification.
  64.  
  65. Furthermore, the library offers some functions which allow to "transform"
  66. a normal gadget into a custom gadget having (almost) the same features of
  67. the "selectgclass" gadgets.
  68.  
  69. This way it's possible, for example, to create GadTools GENERIC_KIND gadgets
  70. and turn them into pop-up gadgets, obtaining all the benefits of this type
  71. of gadgets while also keeping the benefits of the GadTools automatic gadget
  72. creation (and deletion) system.
  73.  
  74. Lastly, this gadget class supports VisualPrefs and takes full advantage of
  75. the graphic enhancements it brings to the system.
  76.  
  77.  
  78. CLASS DOCUMENTATION
  79.  
  80. Class:        selectgclass
  81. Superclass:   gadgetclass
  82. Include File: <gadgets/select.h>
  83.  
  84. A BOOPSI popup gadget which can also behave as a GadTools-like cycle gadget
  85. or even as a normal button gadget. The selectgclass gadget keeps its current
  86. active item value in its SGA_Active attribute, and when it changes because
  87. of user's interaction a notification message is sent to its target and also
  88. (optionally) an IDCMP_GADGETUP message is sent to its window's UserPort.
  89.  
  90. New Methods:
  91.  
  92. None.
  93.  
  94. Changed Methods:
  95.  
  96. OM_NEW - After creation of the gadget by the superclass, this method
  97. initializes the "selectgclass" instance data on the basis of the contents
  98. of the attributes tag list.
  99.  
  100. OM_DISPOSE - This method frees all the resources allocated in the OM_NEW
  101. method.
  102.  
  103. OM_SET, OM_UPDATE - The gadget will automatically refresh its graphic
  104. appearance to reflect any changes to visual attributes, such as the active
  105. item, the gadget position and size, and the gadget text. In particular,
  106. when the gadget is moved, it first erases itself at the old position.
  107.  
  108. GM_RENDER - The rendering of the various "selectgclass" gadget components
  109. (frame, symbol, label, text) is made in a very optimized way. The gadget
  110. clips its graphics at the window borders, and avoids as much as possible
  111. to redraw a single pixel more than once. If gpRender.gpr_Redraw has the
  112. value GREDRAW_UPDATE the gadget redraws only the frame and its contents,
  113. otherwise it also redraws the text.
  114.  
  115. GM_HITTEST - This method currently always returns GMR_GADGETHIT, but don't
  116. count on this being the case also in future versions.
  117.  
  118. GM_GOACTIVE - In this method some precalculations are made and cached, to
  119. speed up the GM_HANDLEINPUT method.
  120.  
  121. GM_HANDLEINPUT - If the user clicks with the mouse select button on the
  122. "pop-up" zone of the gadget (which can be the entire gadget box, or just
  123. a part of it, depending on the value of the SGA_FullPopUp tag), an internal
  124. timer starts.
  125.  
  126. If the button is released before the pop-up delay (set with SGA_PopUpDelay)
  127. expires, the gadget behaves exactly as a GadTools cycle gadget would: if the
  128. mouse pointer was within the gadget box when the button was released, the
  129. gadget's active item changes, and the change is reported to the application
  130. via an IDCMP_GADGETUP IntuiMessage and/or to the gadget's target object via
  131. an OM_UPDATE message.
  132.  
  133. If, instead, the mouse button is kept pressed long enough, a pop-up menu
  134. appears, showing all the available items. However, it the gadget has too few
  135. items (the threshold can be set with the SGA_MinItems tag) the menu doesn't
  136. appear, and the gadget keeps behaving like a cycle gadget.
  137.  
  138. When the menu is displayed, the user can select any of the displayed items
  139. just by moving the mouse pointer on it and releasing the mouse select button.
  140. Alternatively, if the pop-up menu is of the "sticky" type, the user must
  141. first release the mouse button, then move the pointer on the desired choice
  142. and press the button again.
  143.  
  144. If the selected item is different from the previously active one, or if
  145. the SGA_ReportAll attribute is set to TRUE, the new active value is reported
  146. to the application via an IDCMP_GADGETUP IntuiMessage and/or to the gadget's
  147. target object via an OM_UPDATE message.
  148.  
  149. If the mouse select button is initially clicked with the pointer not on
  150. the "pop-up" zone of the gadget, the pop-up menu doesn't appear, and the
  151. gadget behaves like a GadTools cycle gadget, no matter how long the button
  152. is kept pressed.
  153.  
  154. As with GadTools, a SHIFT qualifier causes the gadget to cycle backwards.
  155.  
  156. The gadget reports changes in its SGA_Active attribute value to the
  157. application by sending an IDCMP_GADGETUP IntuiMessage to the UserPort
  158. of its window. The IntuiMessage.Code field contains the new value of
  159. the attribute.
  160.  
  161. The gadget reports changes in its SGA_Active attribute value to its
  162. target object by sending it an OM_UPDATE message. The message's attribute
  163. tag list contains the new value of the attribute and the ID of the gadget.
  164.  
  165. Any operation being made with the "selectgclass" gadget can always be aborted
  166. by pressing the right (menu) button of the mouse.
  167.  
  168. GM_GOINACTIVE - This method does a clean-up after the GM_GOACTIVE method.
  169.  
  170. GM_LAYOUT - In this method, a "selectgclass" gadget does all necessary
  171. calculations to prepare itself for rendering and user interaction.
  172. This method fully support the Intuition relativity flags (GFLG_RELRIGHT,
  173. GFLG_RELBOTTOM, GFLG_RELWIDTH and GFLG_RELHEIGHT).
  174.  
  175. Attributes:
  176.  
  177. GA_Image (IS) - The image the gadget will use to render its frame. If this
  178.                 attribute is not specified, or if it's NULL, a default image
  179.                 will be used (namely, an instance of "frameiclass").
  180.                 If it's set to ~0 (or -1) no image will be rendered.
  181.                 The gadget renders its frame image with the IM_DRAWFRAME
  182.                 method when possible, so it would be a good idea to have
  183.                 your custom image support this.
  184.                 Changing this attribute causes the gadget to be redrawn.
  185.  
  186. GA_Text, GA_IntuiText, GA_LabelImage (IS) - The gadget supports all of these
  187.                                             methods of specifying a text.
  188.                                             Changing one of these attributes
  189.                                             causes the gadget to be redrawn.
  190.                                             See also SGA_TextPlace (below).
  191.                                              
  192. GA_Left, GA_RelRight, GA_Top, GA_RelBottom (IS) - The gadget supports both
  193.                                                   absolute and relative
  194.                                                   positioning. Changing one
  195.                                                   of these attributes causes
  196.                                                   the gadget to be redrawn,
  197.                                                   with its old imagery being
  198.                                                   erased first.
  199.                                                    
  200. GA_Width, GA_RelWidth, GA_Height, GA_RelHeight (IS) - The gadget supports
  201.                                                       both absolute and
  202.                                                       relative sizing.
  203.                                                       Changing one of these
  204.                                                       attributes causes the
  205.                                                       gadget to be redrawn,
  206.                                                       with its old imagery
  207.                                                       being erased first.
  208.                                                       
  209. GA_DrawInfo (I) - A pointer to your screen's DrawInfo structure. If this
  210.                   attribute is specified, and the tag list doesn't contain
  211.                   any explicit information about the gadget's size, the
  212.                   gadget will automatically size itself just large enough to
  213.                   frame its contents. This can work for just one axis, or
  214.                   both, depending on which ones have an explicitly specified
  215.                   size. This attribute is only valid at creation time; you
  216.                   don't need to specify it if you do not want the automatic
  217.                   sizing feature.
  218.  
  219. SGA_Active (ISGNU) - The index number (starting from zero) of the current
  220.                      active item. The default value is zero.
  221.                      Changing this attribute causes the gadget to be redrawn.
  222.  
  223. SGA_Labels (ISU) - A NULL-terminated string array containing all the item
  224.                    labels for the gadget. It can safely be empty. If this
  225.                    attribute is not specified, or if it's NULL, the gadget
  226.                    will look and behave like a traditional button gadget.
  227.                    Changing this attribute causes the gadget to be redrawn.
  228.  
  229. SGA_MinItems (ISGU) - The minimum number of items the gadget must have for
  230.                       the pop-up menu to appear. If the items are fewer than
  231.                       this, the gadget will always behave like a traditional
  232.                       GadTools cycle gadget. The default is zero.
  233.  
  234. SGA_FullPopUp (ISU) - If TRUE, clicking anywhere on the gadget box will
  235.                       cause the pop-up menu to appear (after the requested
  236.                       delay). If FALSE, clicking on the "symbol box" (if
  237.                       one exists) will make the gadget behave like a GadTools
  238.                       cycle gadget. Defaults to FALSE.
  239.  
  240. SGA_PopUpDelay (ISU) - The amount of time (in milliseconds) the gadget must
  241.                        remain pressed for the pop-up menu to appear. If this
  242.                        is zero, the pop-up menu will appear immediately and
  243.                        the gadget won't even change to its "pressed" state.
  244.                        Defaults to zero.
  245.                        
  246. SGA_PopUpPos (ISU) - This attribute determines where the pop-up menu is to
  247.                      appear, relative to the gadget's position. It may have
  248.                      four different values:
  249.                      SGPOS_ONITEM - position the menu so that the the active
  250.                                     item is under the mouse pointer.
  251.                      SGPOS_ONTOP - always align the top edge of the menu with
  252.                                    the top edge of the gadget.
  253.                      SGPOS_BELOW - place the menu just below the gadget.
  254.                      SGPOS_RIGHT - place the menu at the right side of gadget,
  255.                                    aligning its top edge with the gadget's
  256.                                    top edge.
  257.                      With the exception of SGPOS_RIGHT, all the values center
  258.                      the menu horizontally on the "popup" zone of the gadget.
  259.                      The default is SGPOS_ONITEM.
  260.  
  261. SGA_MinTime (ISU) - The minimum duration of the menu panel's opening/closing
  262.                     animation effect, in milliseconds. You can set this to a
  263.                     value greater than zero to make sure the effect can be
  264.                     noticed even with gadgets having a very small number of
  265.                     items. The default is zero. (V40.14)
  266.                     
  267. SGA_MaxTime (ISU) - The maximum duration of the menu panel's opening/closing
  268.                     animation effect, in milliseconds. You can set this to a
  269.                     small value to make sure the effect doesn't take too much
  270.                     time with gadgets having a very large number of items.
  271.                     If set to zero, the effect doesn't take place at all.
  272.                     The default is zero. (V40.14)
  273.  
  274. SGA_Sticky (ISU) - If FALSE, the pop-up menu will close as soon as the user
  275.                    releases the mouse button. If TRUE, the menu will remain
  276.                    open after the button is released, and will close when the
  277.                    user clicks on it to select an item, or somewhere else to
  278.                    abort the operation. Defaults to FALSE.
  279.                    Changing this attribute causes the gadget to be redrawn
  280.                    (to change the symbol image), unless you are using a
  281.                    custom symbol.
  282.  
  283. SGA_PanelMode (ISU) - This attribute specifies the way the menu panel will
  284.                       be rendered to the screen. It can have three different
  285.                       values:
  286.                       SGPM_WINDOW - the panel will be a normal Intuition
  287.                                     window. This is the most system-friendly
  288.                                     mode, and does not block graphic output
  289.                                     to the screen, but it's also slower and
  290.                                     more sluggish than the other two modes.
  291.                       SGPM_DIRECT_NB - the panel will be rendered directly to
  292.                                        the screen's bitmap, without blocking
  293.                                        graphic output to the screen.
  294.                       SGPM_DIRECT_B - the panel will be rendered directly to
  295.                                       the screen's bitmap, blocking graphic
  296.                                       output to the screen.
  297.                       The last two modes give a very smoother visual feedback
  298.                       (especially with the opening/closing animation effect)
  299.                       but might also cause unexpected results under some rare
  300.                       circumstances. The default is SGPM_WINDOW. (V40.14)
  301.  
  302. SGA_TextAttr (ISU) - Pointer to a TextAttr structure describing the font
  303.                      to be used for the gadget's text and labels. The font
  304.                      must be already in memory and openable with OpenFont();
  305.                      if not, the screen font will be used instead.
  306.                      This attribute is overridden by SGA_TextFont.
  307.                      Changing this attribute causes the gadget to be redrawn,
  308.                      unless there's a valid font specified with SGA_TextFont.
  309.  
  310. SGA_TextFont (ISU) - Pointer to a TextFont structure which is to be used for
  311.                      rendering the gadget's text and labels. This overrides
  312.                      the SGA_TextAttr attribute. If both attributes are NULL
  313.                      or not specified, the screen font will be used.
  314.                      The font whose pointer you pass with this tag must
  315.                      remain open for the whole life of the gadget.
  316.                      Changing this attribute causes the gadget to be redrawn.
  317.  
  318. SGA_TextPlace (ISGU) - The position at which the gadget's text is to be
  319.                        rendered. It can assume one of the five PLACETEXT_#?
  320.                        values defined in <libraries/gadtools.h>. If this is
  321.                        not specified, PLACETEXT_LEFT is assumed, unless the
  322.                        gadget has no items (that is, it's a button gadget)
  323.                        in which case PLACETEXT_IN is assumed.
  324.                        This works also if the text is really an image label.
  325.                        Changing this attribute causes the gadget to be
  326.                        redrawn, with the text in the new position.
  327.                        Note: currenty this attribute MUST be specified if the
  328.                        gadget uses an IntuiText for its text, whereas it can
  329.                        be optional if the text is a string or an image label.
  330.                        
  331. SGA_Underscore (ISU) - The symbol preceding the character in the gadget text
  332.                        to be underscored. This can be to indicate keyboard
  333.                        equivalents for gadgets (note that "selectgclass" does
  334.                        not process the keys; it just displays the underscore).
  335.                        This attribute is only used if the gadget text is a
  336.                        simple string; if you use an IntuiText or an image,
  337.                        you must provide your own underscoring.
  338.                        The value of this attribute is a simple UBYTE.
  339.                        Changing this attribute causes the gadget to be
  340.                        redrawn.
  341.  
  342. SGA_Justify (ISU) - The alignment of the active label within the "text zone"
  343.                     of the gadget box. It can be SGJ_LEFT, SGJ_CENTER or
  344.                     SGJ_RIGHT. The default is SGJ_CENTER.
  345.                     Changing this attribute causes the gadget to be redrawn.
  346.                     Note: SGJ_RIGHT is not yet implemented.
  347.  
  348. SGA_Quiet (ISU) - If TRUE, the gadget's active label will not be displayed
  349.                   within the gadget box. Defaults to FALSE.
  350.                   Changing this attribute causes the gadget to be redrawn.
  351.  
  352. SGA_Symbol (ISU) - Pointer to a standard or BOOPSI image structure, to be
  353.                    used as the "pop-up" symbol (akin to the "cycle" symbol
  354.                    of GadTools cycle gadgets) which is usually displayed
  355.                    at the left or right side of a "selectgclass" gadget.
  356.                    The image, if BOOPSI, is rendered within the symbol box
  357.                    using the IM_DRAWFRAME method, so try to support this.
  358.                    If NULL or not specified, a default (scalable) internal
  359.                    image will be used, whose look depends on the gadget type
  360.                    (sticky or non-sticky).
  361.                    If this is ~0 (or -1) no symbol will be displayed.
  362.                    Changing this attribute causes the gadget to be redrawn.
  363.  
  364. SGA_SymbolWidth (ISGU) - The width of the "symbol box", that is, the part of
  365.                          the gadget box (usually delimited by a separator
  366.                          line) which contains the "pop-up" symbol. It is
  367.                          advised not to make it too wide, or there could be
  368.                          insufficient room for the gadget's active label.
  369.                          The default is 21 (like for GadTools cycle gadgets).
  370.                          Changing this attribute causes the gadget to be
  371.                          redrawn.
  372.  
  373. SGA_SymbolOnly (ISU) - If TRUE, only the symbol box will be selectable, while
  374.                        the rest of the gadget will appear recessed and will
  375.                        be read-only. Defaults to FALSE.
  376.                        Changing this attribute causes the gadget to be
  377.                        redrawn.
  378.  
  379. SGA_Separator (ISU) - If TRUE, a recessed separator line will be drawn
  380.                       between the symbol and the active label in the gadget
  381.                       box. Defaults to TRUE.
  382.                       Changing this attribute causes the gadget to be redrawn.
  383.  
  384. SGA_ListFrame (ISU) - Pointer to a standard or BOOPSI image to be used as
  385.                       the background of the pop-up menu panel. When possible
  386.                       it is rendered with the IM_DRAWFRAME method, so try to
  387.                       support this. If NULL or not specified, a default image
  388.                       will be used (an instance of "frameiclass").
  389.  
  390. SGA_DropShadow (ISU) - If TRUE, a four-pixel thick dithered drop shadow will
  391.                        appear under the pop-up menu. Defaults to FALSE.
  392.  
  393. SGA_ItemSpacing (ISU) - The number of pixels which is to be added to the
  394.                         gadget's font height in order to determine the height
  395.                         of an item in the pop-up menu. The result of the sum
  396.                         will be ignored if it is smaller than the value of
  397.                         the SGA_ItemHeight attribute (see below). The default
  398.                         is zero.
  399.                        
  400. SGA_ItemHeight (ISU) - The exact height of each item in the pop-up menu.
  401.                        It can never be less than the gadget's font height
  402.                        plus the value of the SGA_ItemSpacing attribute.
  403.                        Defaults to the gadget's font height plus the value
  404.                        of the SGA_ItemSpacing attribute.
  405.  
  406. SGA_ListJustify (ISU) - The alignment of labels within the pop-up menu panel.
  407.                         It can be SGJ_LEFT, SGJ_CENTER or SGJ_RIGHT. The
  408.                         default is SGJ_CENTER.
  409.                         Note: SGJ_RIGHT is not yet implemented.
  410.                         
  411. SGA_ActivePens (ISU) - Pointer to an array of four UWORDs containing the
  412.                        pen numbers to be used for rendering the active item
  413.                        in the pop-up menu panel. The meaning of the array
  414.                        index is: 0 - color of the text; 1 - color of the
  415.                        background; 2 - color of the bright edges; 3 - color
  416.                        of the dark edges.
  417.                        These are actual color numbers, not Intuition pen
  418.                        numbers.
  419.                        Defaults to using the colors of FILLTEXTPEN, FILLPEN,
  420.                        SHINEPEN and SHADOWPEN (although the presence of the
  421.                        VisualPrefs patch might change these defaults).
  422.  
  423. SGA_ActiveBox (ISU) - If this is not zero, the active item in the pop-up
  424.                       menu panel will have a 3D frame around it. The frame
  425.                       will be recessed if this attribute is -1, otherwise
  426.                       it will be raised. The colors are determined with the
  427.                       SGA_ActivePens tag. Defaults to zero (no frame).
  428.  
  429. SGA_BorderSize (ISU) - The thickness of the border to be left between the
  430.                        edges of the pop-up menu panel and the displayed
  431.                        labels. If it is set to -1, a suitable value will be
  432.                        chosen automatically. Defaults to -1.
  433.  
  434. SGA_FullWidth (ISU) - If TRUE, the pop-up menu will have the same width of
  435.                       the entire gadget; if FALSE, it will have the width of
  436.                       the gadget minus the width of the symbol box. Defaults
  437.                       to FALSE.
  438.  
  439. SGA_FollowMode (ISU) - Determines the behavior of the pop-up menu when the
  440.                        mouse pointer goes out of its boundaries. There are
  441.                        three possible values:
  442.                        SGFM_NONE - the active item becomes not highlighted.
  443.                        SGFM_KEEP - the active item remains highlighted, but
  444.                                    doesn't change until the pointer returns
  445.                                    on the panel.
  446.                        SGFM_FULL - the active item remains highlighted, and
  447.                                    can also change if the user moves the
  448.                                    pointer up and down, even if outside of
  449.                                    the menu panel.
  450.                        If the gadget is not sticky, and the user lets go of
  451.                        the mouse select button while the pointer is outside
  452.                        of the menu panel, the currently highlighted item will
  453.                        be selected, if there is one.
  454.                        The default is SGFM_NONE.
  455.                        
  456. SGA_ReportAll (ISU) - If TRUE, the gadget reports the selection of an item
  457.                       even if it was already the active item. If FALSE, a
  458.                       selection is only reported when the active item
  459.                       actually changes. Defaults to FALSE.
  460.                       Note: if there are no items (that is, if the gadget
  461.                       is really a button gadget) this attribute is currently
  462.                       ignored, and assumed TRUE.
  463.  
  464. SGA_Refresh (SU) - This is not a real attribute; if you pass this tag with
  465.                    a value of TRUE, it will force an immediate refresh of the
  466.                    gadget's imagery. This is only useful for custom select
  467.                    gadgets obtained with the InitSelectGadgetA() function, as
  468.                    the usual RefreshGadgets() and RefreshGList() functions
  469.                    aren't always sufficient to refresh them correctly.
  470.                    Real "selectgclass" BOOPSI gadgets shouldn't need this tag.
  471.  
  472.  
  473. USER CONFIGURATION AND PROGRAMMING STYLE
  474.  
  475. Although the "selectgclass" class offers many attributes to customize its
  476. look and behavior, programmers should not explicitly set the value of the
  477. ones which don't influence the working of their applications, or else the
  478. user would be confused by a multitude of differently-looking gadgets.
  479.  
  480. Usually, the only attributes you really need to specify in your code are
  481. SGA_Active, SGA_Labels, SGA_TextPlace, SGA_Underscore, SGA_Quiet, SGA_Symbol,
  482. SGA_ListFrame and SGA_ReportAll (plus the various GA_#? ones).
  483. If you also use SGA_TextAttr or SGA_TextFont, it would be a good idea to
  484. offer the user a way to choose the font and size to be used.
  485.  
  486. Of course, nothing stops you from using other attributes too, but it's a
  487. better style to do so only when it's really needed. For attributes which
  488. are transparent to your application, it is advised that you respect the
  489. default values.
  490.  
  491. Such default values, for the most significant attributes defining the look
  492. and feel of the gadgets, can be globally set by the user in a preferences
  493. file, called "ENV:Gadgets/select.prefs".
  494.  
  495. The attribute values found in the preferences file override the built-in
  496. default values for the corresponding tags; if an attribute isn't present
  497. in the file, or if the file is not found, it will keep using the value
  498. most recently set (the initial one being the built-in default).
  499.  
  500. As the preferences file is just ASCII text, the user can edit it by hand
  501. to change the desired attributes. The format of the file is very simple; it
  502. is a list of tool types named exactly like the corresponding "selectgclass"
  503. tags, minus the SGA_ prefix.
  504.  
  505. An example of file would be:
  506.  
  507.    ItemSpacing=3
  508.    FullWidth=1
  509.    PopUpDelay=250
  510.  
  511. As of now, the attributes settable by the user are the following ones ("inf"
  512. means "infinite"):
  513.  
  514. Attribute     Range      Type       Default
  515.  
  516. MinItems      [ 1..inf]  (integer)  1
  517. FullPopUp     [ 0, 1  ]  (boolean)  0
  518. PopUpDelay    [ 0..inf]  (integer)  0
  519. PopUpPos      [ 0..3  ]  (integer)  0
  520. Sticky        [ 0, 1  ]  (boolean)  0
  521. Justify       [ 0..2  ]  (integer)  1
  522. Separator     [ 0, 1  ]  (boolean)  1
  523. DropShadow    [ 0, 1  ]  (boolean)  0
  524. ItemSpacing   [ 0..inf]  (integer)  0
  525. ListJustify   [ 0..2  ]  (integer)  1
  526. ActiveBox     [-1..1  ]  (integer)  0
  527. BorderSize    [-1..inf]  (integer) -1
  528. FullWidth     [ 0, 1  ]  (boolean)  0
  529. FollowMode    [ 0..2  ]  (integer)  0
  530. PanelMode     [ 0..2  ]  (integer)  0
  531. MinTime       [ 0..Inf]  (integer)  0
  532. MaxTime       [ 0..Inf]  (integer)  0
  533.  
  534.  
  535. TO DO
  536.  
  537. Future releases should add the following features:
  538.  
  539.  o More attributes globally settable by the user.
  540.  
  541.  o Ability to display read-only pop-up menus.
  542.  
  543.  o Ability to generate "repeat" messages if the gadget is kept pressed for
  544.    a while (only when it's a button gadget). Useful for making arrow buttons.
  545.  
  546.  o Ability to only display the menu on a button release. Would make sense
  547.    for "sticky" gadgets.
  548.  
  549.  o Text clipping for the gadget item labels.
  550.  
  551.  o Some more code optimization.
  552.  
  553.  
  554. HISTORY
  555.  
  556. 40.15 (19.6.99)
  557.    Now the gadget preserves the pen color of any IntuiText passed to it
  558.    rather than incorrectly changing it to TEXTPEN.
  559.  
  560. 40.14 (14.1.99)
  561.    - Added the ability to do direct bitmap rendering (instead of opening a
  562.      window) for the pop-up menu panel, which gives a much smoother visual
  563.      feedback.
  564.    - Now the menu panel can have an opening/closing "zoom" effect with a
  565.      configurable duration.
  566.    - The drop shadow edges have now the correct shape when the "round edges"
  567.      option of VisualPrefs is active.
  568.    - Now the background process handling global preferences has a name.
  569.  
  570. 40.13 (17.11.98)
  571.    Slightly enhanced the GM_RENDER method.
  572.  
  573. 40.12 (25.5.98)
  574.    First public release.
  575.  
  576. select.gadget/select.gadget                       select.gadget/select.gadget
  577.  
  578.    NAME
  579.       select.gadget -- create a pop-up, cycle or button BOOPSI gadget
  580.  
  581.    FUNCTION
  582.       The select.gadget shared library implements a public BOOPSI gadget
  583.       class, called "selectgclass", which provides gadgets with the ability
  584.       to display a pop-up menu allowing the user to pick up a choice among
  585.       a number of alternatives.
  586.       The "selectgclass" gadgets can also be used as standard GadTools-like
  587.       cycle gadgets, or even as simple button gadgets.
  588.       Nearly every aspect of their look and behavior can be configured
  589.       using tag items which give access to the class attributes.
  590.  
  591.       For a complete description of the "selectgclass" class and its features,
  592.       see the class reference documentation in the --background-- paragraph.
  593.  
  594.       The library also supplies some functions allowing to modify an
  595.       existing, non-BOOPSI gadget in order to make it a custom gadget
  596.       using the hook function of "selectgclass". This makes it possible
  597.       to use normal gadgets, such as GadTools GENERIC_KIND ones, as if
  598.       they were "selectgclass" BOOPSI gadgets (with some minor limitations,
  599.       mainly the lack of notification abilities).
  600.  
  601.       To be able to create and use "selectgclass" objects in an application,
  602.       you first have to open the select.gadget library with OpenLibrary().
  603.       Once you have done this, you shouldn't close the library until all of
  604.       your "selectgclass" objects have been freed.
  605.  
  606.    TAGS
  607.       For the full list of "selectgclass" attributes, see the class reference
  608.       documentation in the --background-- paragraph.
  609.  
  610.    NOTES
  611.       The "selectgclass" gadget class currently does not support adding
  612.       gadgets to a screen titlebar. This feature shouldn't be needed anyway.
  613.  
  614.    WARNING
  615.       Don't close the select.gadget library if you still have some instances
  616.       of "selectgclass" gadgets hanging around!
  617.  
  618.    BUGS
  619.       None known.
  620.  
  621. select.gadget/ClearSelectGadget               select.gadget/ClearSelectGadget
  622.  
  623.    NAME
  624.       ClearSelectGadget -- strip a gadget of all additional information.
  625.  
  626.    SYNOPSIS
  627.       ClearSelectGadget(gadget);
  628.                         A0
  629.  
  630.       void ClearSelectGadget(struct Gadget *);
  631.  
  632.    FUNCTION
  633.       Strips a gadget of all the addition information which was added by
  634.       InitSelectGadgetA(), and restores it (as much as possible) to its
  635.       former state. You should only call this function on gadgets that were
  636.       successfully modified by InitSelectGadgetA(), and call it only once.
  637.  
  638.    INPUTS
  639.       gadget - pointer to a custom gadget initialized by InitSelectGadgetA()
  640.  
  641.    NOTES
  642.       Once cleared, the gadget can still be used as a traditional gadget,
  643.       although in most cases this probably won't make much sense.
  644.  
  645.    BUGS
  646.       None known.
  647.  
  648.    SEE ALSO
  649.       InitSelectGadgetA()
  650.  
  651. select.gadget/GetSGAttr                               select.gadget/GetSGAttr
  652.  
  653.    NAME
  654.       GetSGAttr -- get value of an attribute of a non-BOOPSI select gadget.
  655.  
  656.    SYNOPSIS
  657.       result = GetSGAttr(attrid, gadget, storageptr);
  658.       D0                 D0      A0      A1
  659.  
  660.       ULONG GetSGAttr(ULONG, struct Gadget *, ULONG *);
  661.  
  662.    FUNCTION
  663.       Inquires from the specified gadget the value of the specified
  664.       attribute. The gadget must be a non-BOOPSI gadget successfully
  665.       modified by InitSelectGadgetA(), and the attribute must be specific
  666.       to "selectgclass". Do not attempt to get standard "gadgetclass"
  667.       attributes with this function.
  668.       
  669.       You always pass the address of a LONG variable, which will receive
  670.       the same value that would be passed to SetSGAttrsA() in the ti_Data
  671.       portion of a TagItem element.
  672.       
  673.       Not all attributes will respond to this function. Those which do are
  674.       marked with the "G" applicability flag in the "Attributes" list found
  675.       in the class reference documentation (see --background-- paragraph).
  676.  
  677.    INPUTS
  678.       attrid - an attribute tag ID understood by "selectgclass"
  679.       gadget - pointer to a custom select gadget
  680.       storageptr - pointer to appropriate storage for the answer
  681.  
  682.    RESULT
  683.       result - FALSE if the inquiries of the specified attribute are not
  684.                provided by "selectgclass", TRUE otherwise
  685.  
  686.    NOTES
  687.       Don't call this function on real BOOPSI "selectgclass" objects; use
  688.       intuition.library/GetAttr() instead.
  689.  
  690.    BUGS
  691.       None known.
  692.  
  693.    SEE ALSO
  694.       InitSelectGadgetA(), ClearSelectGadget(), SetSGAttrsA()
  695.  
  696. select.gadget/InitSelectGadgetA               select.gadget/InitSelectGadgetA
  697.  
  698.    NAME
  699.       InitSelectGadgetA -- change a gadget into a "selectgclass"-like gadget.
  700.       InitSelectGadget -- varargs stub for InitSelectGadgetA().
  701.  
  702.    SYNOPSIS
  703.       success = InitSelectGadgetA(gadget, flags, taglist)
  704.       D0                          A0      D0     A1
  705.       
  706.       ULONG InitSelectGadgetA(struct Gadget *, ULONG, struct TagItem *);
  707.       
  708.       success = InitSelectGadget(gadget, flags, firsttag, ...)
  709.  
  710.       ULONG InitSelectGadget(struct Gadget *, ULONG, Tag, ...);
  711.  
  712.    FUNCTION
  713.       The purpose of this function is to modify an already existing gadget
  714.       in order to make it a custom gadget which uses the same hook function
  715.       used by the "selectgclass" BOOPSI gadgets.
  716.  
  717.       This function can be very useful if you have already written a program
  718.       using a non-BOOPSI framework for its GUI (such as GadTools), as it
  719.       allows you to make your program use the "select" gadgets without having
  720.       to intermix BOOPSI code with the already existing non-BOOPSI code.
  721.  
  722.       In the case of GadTools, for example, you could create GENERIC_KIND
  723.       gadgets instead of CYCLE_KIND gadgets, and later use InitSelectGadgetA()
  724.       to turn them into pop-up gadgets. You would then continue handling
  725.       your interface exactly as before, and once you are done with your
  726.       gadgets you would just have to restore them to their original state
  727.       (using the ClearSelectGadget() function) before deleting them as usual
  728.       with gadtools.library/FreeGadgets().
  729.  
  730.       InitSelectGadgetA() does all necessary allocations, and appends some
  731.       information to the gadget structure. This information is initialized
  732.       on the basis of the attribute/value couples you pass in the tag list.
  733.       The tag list can only contain attributes specific to "selectgclass"
  734.       (SGA_#?), with the _only_ exception being the "gadgetclass" GA_Image
  735.       attribute, which can be passed to the function.
  736.       Every other "standard" gadget attribute (GA_#?) can't be passed to
  737.       InitSelectGadgetA(), but must be set in the gadget structure by hand.
  738.  
  739.       However, once the structure has been modified by InitSelectGadgetA(),
  740.       and until it is restored by ClearSelectGadget(), some restrictions
  741.       apply to what you're allowed to do with its fields.
  742.  
  743.       More precisely, you may read and write the following fields ONLY:
  744.       
  745.       NextGadget
  746.       LeftEdge, TopEdge, Width, Height
  747.       GadgetText
  748.       GadgetID
  749.       UserData
  750.       BoundsLeftEdge, BoundsTopEdge, BoundsWidth, BoundsHeight
  751.       
  752.       You may also read, set and clear the following flag bits:
  753.  
  754.       GFLG_RELBOTTOM, GFLG_RELRIGHT, GFLG_RELWIDTH, GFLG_RELHEIGHT
  755.       GFLG_DISABLED
  756.       GFLG_LABELSTRING, GFLG_LABELIMAGE
  757.       GACT_RELVERIFY
  758.       GMORE_GADGETHELP
  759.       
  760.       The following flag bits are read-only:
  761.       
  762.       GFLG_IMAGEDISABLE
  763.       GFLG_EXTENDED
  764.       GACT_LEFTBORDER, GACT_TOPBORDER, GACT_RIGHTBORDER, GACT_BOTTOMBORDER
  765.       GACT_ENDGADGET
  766.       GTYP_SCRGADGET (not supported yet)
  767.       GTYP_GZZGADGET
  768.       GTYP_REQGADGET
  769.       GMORE_BOUNDS
  770.  
  771.       All the above public fields and flag bits, even the read-only ones, may
  772.       be set BEFORE calling InitSelectGadgetA(), which will preserve them.
  773.       The only exception is the GACT_RELVERIFY bit: the function will always
  774.       set it, but you can clear it later (doesn't make much sense though,
  775.       as you would be no longer able to hear anything from the gadget).
  776.  
  777.       Note well: all remaining fields and flag bits are considered PRIVATE
  778.       and should NOT be used nor relied on.
  779.  
  780.       To set/change the gadget's image, always use the GA_Image tag. Don't
  781.       touch the GadgetRender field!
  782.  
  783.       Also, if you modify by hand some values in the gadget structure which
  784.       could cause a change in the gadget visual appearance, such as its
  785.       position, size or text, you can force a refresh of the gadget by
  786.       calling SetSGAttrsA() with the couple { SGA_Refresh, TRUE }. Using
  787.       RefreshGadgets() or RefreshGList() is not sufficient in this case.
  788.       
  789.       Once your custom select gadget is no longer needed, you should strip it
  790.       of all the added information by using the ClearSelectGadget() function.
  791.       This will turn the gadget back into whatever it was before you called
  792.       InitSelectGadgetA().
  793.       
  794.    INPUTS
  795.       gadget - pointer to a non-BOOPSI gadget which will be transformed into
  796.                a custom gadget using the hook function of "selectgclass"; it
  797.                can safely be NULL, in which case the function returns failure
  798.       flags - reserved for future use; please set this to zero for now
  799.       taglist - pointer to an array of tags providing extra parameters, or
  800.                 NULL
  801.                 
  802.    TAGS
  803.       For the full list of "selectgclass" attributes, see the class reference
  804.       documentation in the --background-- paragraph.
  805.  
  806.    RESULT
  807.       success - TRUE if all went ok, FALSE otherwise. If FALSE the gadget
  808.                 has not been changed, so you don't have to clear it with
  809.                 ClearSelectGadget()
  810.  
  811.    EXAMPLE
  812.       Your already existing GadTools code might be looking like this:
  813.       
  814.          ...
  815.          newgadget.ng_GadgetText = "Qualifier:";
  816.          newgadget.ng_Flags = PLACETEXT_ABOVE;
  817.          ...
  818.          gad = CreateGadget(CYCLE_KIND,gad,&newgadget,GTCY_Labels,labels,
  819.                                                       GTCY_Active,active,
  820.                                                       TAG_END);
  821.          ...
  822.  
  823.          
  824.       To use the "selectgclass" features, you could modify it this way:
  825.       
  826.          ...
  827.          newgadget.ng_GadgetText = "Qualifier:";
  828.          ...
  829.          gad = CreateGadget(GENERIC_KIND,gad,&newgadget,TAG_END);
  830.          
  831.          if (!InitSelectGadget(gad,0L,SGA_Labels,labels,
  832.                                       SGA_Active,active,
  833.                                       SGA_TextPlace,PLACETEXT_ABOVE,
  834.                                       TAG_END))
  835.          {
  836.             gad = NULL;  // From now on, all CreateGadget() calls will fail
  837.          }
  838.          
  839.          ...
  840.  
  841.    BUGS
  842.       None known.
  843.  
  844.    SEE ALSO
  845.       ClearSelectGadget()
  846.  
  847. select.gadget/ObtainSelectGClass             select.gadget/ObtainSelectGClass
  848.  
  849.    NAME
  850.       ObtainSelectGClass -- return a pointer to "selectgclass".
  851.  
  852.    SYNOPSIS
  853.       sgclass = ObtainSelectGClass()
  854.       D0
  855.  
  856.       Class *ObtainSelectGClass(void);
  857.  
  858.    FUNCTION
  859.       Returns a pointer to the class implemented by the select.gadget, called
  860.       "selectgclass". Use this pointer with care, and do not reference it
  861.       after you've closed the select.gadget library.
  862.       
  863.    INPUTS
  864.       none
  865.  
  866.    RESULT
  867.       sgclass - pointer to the class
  868.  
  869.    BUGS
  870.       None known.
  871.  
  872.    SEE ALSO
  873.  
  874. select.gadget/SetSGAttrsA                           select.gadget/SetSGAttrsA
  875.  
  876.    NAME
  877.       SetSGAttrsA -- change the attributes of a non-BOOPSI select gadget.
  878.       SetSGAttrs -- varargs stub for SetSGAttrsA().
  879.  
  880.    SYNOPSIS
  881.       result = SetSGAttrsA(gadget, window, requester, flags, taglist)
  882.       D0                   A0      A1      A2         D0     A3
  883.       
  884.       ULONG SetSGAttrsA(struct Gadget *, struct Window *, 
  885.                         struct Requester *, ULONG, struct TagItem *);
  886.  
  887.       result = SetSGAttrs(gadget, window, requester, flags, firsttag, ...)
  888.  
  889.       ULONG SetSGAttrs(struct Gadget *, struct Window *,
  890.                        struct Requester *, ULONG, Tag, ...);
  891.  
  892.    FUNCTION
  893.       Changes the attributes of a gadget modified by InitSelectGadgetA(),
  894.       according to the attributes chosen in the tag list. If an attribute
  895.       is not provided in the tag list, its value remains unchanged.
  896.  
  897.       This function is only able to change the attributes which are
  898.       specific to "selectgclass", as well as the GA_Image attribute.
  899.       Any other standard "gadgetclass" attribute is not recognized, so
  900.       do NOT pass such attributes to SetSGAttrsA().
  901.  
  902.       The gadget will refresh its imagery to reflect changes to visual
  903.       attributes, such as the active item, the "pop-up" symbol or the
  904.       gadget's frame image. If you also want to change standard gadget
  905.       attributes (like position, size and gadget text), first change them
  906.       by hand in the gadget structure, then call this function with the
  907.       tag item { SGA_Refresh, TRUE }, which will force a refresh.
  908.       See the documentation of InitSelectGadgetA() for a list of the fields
  909.       in the gadget structure that you are allowed to change by hand.
  910.  
  911.       This function is provided to let you change the special attributes of
  912.       non-BOOPSI gadgets that were initialized by InitSelectGadgetA(); you
  913.       may not call intuition.library/SetGadgetAttrsA() on this special kind
  914.       of gadgets. The opposite is also true: this function must not be used
  915.       with real BOOPSI gadgets (not even "selectgclass" ones).
  916.  
  917.    INPUTS
  918.       gadget - pointer to a custom gadget initialized by InitSelectGadgetA().
  919.                It may be NULL, in which case this function does nothing
  920.       window - pointer to the window containing the gadget. It may be NULL,
  921.                in which case the internal attributes of the gadget are
  922.                altered but no rendering occurs
  923.       requester - pointer to the requester containing the gadget, required
  924.                   only for REQGADGETs
  925.       flags - reserved for future use; please set this to zero for now
  926.       taglist - array of TagItem structures with attribute/value pairs
  927.       
  928.    TAGS
  929.       For the full list of "selectgclass" attributes, see the class reference
  930.       documentation in the --background-- paragraph, and only consider the
  931.       attributes with the "S" applicability flag.
  932.  
  933.    RESULT
  934.       result - TRUE if all went ok, or FALSE if there was an error (usually
  935.                a failure in some memory allocation)
  936.  
  937.    NOTES
  938.       Never, ever call this function with real "selectgclass" BOOPSI gadgets;
  939.       use intuition.library/SetGadgetAttrsA() instead.
  940.  
  941.    BUGS
  942.       None known.
  943.  
  944.    SEE ALSO
  945.       InitSelectGadgetA(), ClearSelectGadget(), GetSGAttr()
  946.  
  947.